﻿Option Strict On
Option Explicit On
Imports System.Runtime.InteropServices
Public Class SHOW_PROPS
    Public Const SW_SHOW As Short = 5
    Public Const SEE_MASK_INVOKEIDLIST As Short = 12
    Private m_fileName As String
    Private m_handle As IntPtr
    Public Sub New(ByVal fileName As String, ByRef hndl As IntPtr)
        m_fileName = fileName
        m_handle = hndl
        Call ShowProperties()
    End Sub
    Public Structure SHELLEXECUTEINFO
        Public cbSize As Integer
        Public fMask As Integer
        Public hwnd As IntPtr
        <MarshalAs(UnmanagedType.LPTStr)> Public lpVerb As String
        <MarshalAs(UnmanagedType.LPTStr)> Public lpFile As String
        <MarshalAs(UnmanagedType.LPTStr)> Public lpParameters As String
        <MarshalAs(UnmanagedType.LPTStr)> Public lpDirectory As String
        Dim nShow As Integer
        Dim hInstApp As IntPtr
        Dim lpIDList As IntPtr
        <MarshalAs(UnmanagedType.LPTStr)> Public lpClass As String
        Public hkeyClass As IntPtr
        Public dwHotKey As Integer
        Public hIcon As IntPtr
        Public hProcess As IntPtr
    End Structure
    <DllImport("Shell32", CharSet:=CharSet.Auto, SetLastError:=True)> _
    Public Shared Function ShellExecuteEx(ByRef lpExecInfo As SHELLEXECUTEINFO) As Boolean
    End Function
    Private Sub ShowProperties()
        Dim sei As New SHELLEXECUTEINFO
        sei.cbSize = Marshal.SizeOf(sei)
        sei.lpVerb = "properties"
        sei.lpFile = m_fileName
        sei.nShow = SW_SHOW
        sei.fMask = SEE_MASK_INVOKEIDLIST
        sei.hwnd = m_handle
        Try
            ShellExecuteEx(sei)
        Catch ex As Exception
            MsgBox(ex.ToString & vbCrLf & ex.StackTrace.ToString)
        End Try
    End Sub
End Class
